import express from 'express';
import * as infoFieldRouter from './infoField.conteroller';
import { fileInterceptor, fileProcessor } from './infoField.middeleware';
import { validateLoginData, authGuard, userGuard } from '../auth/auth.middleware';

const router = express.Router();

/**
 * 获取内容
 */
router.get('/infoField', userGuard, infoFieldRouter.index);

/**
 * 获取内容(按 ID)
 */
router.get('/infoField/:postId', userGuard, infoFieldRouter.infoFieldDetail);

/**
 * 按关键字查询（模糊查询）
 */
router.get('/getInfoFieldByKey', infoFieldRouter.selectByKey);

/**
 * 创建内容
 */
router.post('/infoField', authGuard, infoFieldRouter.store);

/**
 * 更新内容
 */
router.patch('/infoField/:postId', infoFieldRouter.update);

/**
 * 删除内容
 */
router.delete('/infoField/:postId', authGuard, infoFieldRouter.destroy);
router.post('/infoFieldDestroy', authGuard, infoFieldRouter.destroy);

/**
 * 修改状态
 */
router.patch('/infoFieldStatus', authGuard, infoFieldRouter.status);

/**
 * 上传文件
 */
router.post('/infoFieldFiles', authGuard, fileInterceptor, fileProcessor, infoFieldRouter.uploads);

/**
 * 文件服务
 */
router.get('/infoFieldFiles/:fileId/serve', infoFieldRouter.serve);

/**
 * 获取文件 ID
 */
router.post('/getInfoFieldFilesId', infoFieldRouter.getFileName)

/**
 * 导出路由
 */
export default router;
